//
//  FLPrivacyAgreement.m
//  FeeLing
//
//  Created by 乔光玉 on 2019/1/4.
//  Copyright © 2019年 大仙儿飘. All rights reserved.
//

#import "FLPrivacyAgreement.h"



@interface FLPrivacyAgreement()
{
    UIView * atekspabackView;
    UIButton *atcancelButton;
    UIButton *attureButton;
}
@end
@implementation FLPrivacyAgreement

-(void)initView{
    
    atekspabackView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREENWIDTH, SCREENHEIGHT)];
    atekspabackView.backgroundColor = [UIColor blackColor];
    atekspabackView.alpha = 0.5;
    atekspabackView.userInteractionEnabled = YES ;
    [self addSubview:atekspabackView];
    
    
  
    
    
    UIView * ekspabgview = [[UIView alloc]initWithFrame:CGRectMake(SCREENWIDTH/2-135, SCREENHEIGHT/2-215, 270, 430)];
    
    ekspabgview.backgroundColor = [UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0];
    ekspabgview.layer.cornerRadius = 8;
    ekspabgview.clipsToBounds = YES;
    [self addSubview:ekspabgview];
    
    
    
    
    UILabel * tekspaLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 18, ekspabgview.width, 22)];
    tekspaLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:16];
    tekspaLabel.textAlignment = NSTextAlignmentCenter;
    tekspaLabel.numberOfLines = 0 ;
    tekspaLabel.text =NSLocalizedString(@"yinsizhengce", nil);
    tekspaLabel.textColor= [UIColor colorWithHexString:@"#000000"];
    [ekspabgview addSubview:tekspaLabel];
    
    
    
    
    
    UITextView * ekspatext = [[UITextView alloc]initWithFrame:CGRectMake(17, 57, ekspabgview.width-34, ekspabgview.height-57-69)];
    ekspatext.backgroundColor =[UIColor clearColor];
    ekspatext.alpha = 1;
    
    
    ekspatext.font = [UIFont fontWithName:@"PingFangSC-Regular" size:12];
    ekspatext.textColor =  [UIColor colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:1.0];
    ekspatext.editable = NO;
    
    NSArray *appLanguages = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"];
    NSString *languageName = [appLanguages objectAtIndex:0];
    if ([languageName containsString:@"zh"]) {
        ekspatext.text = [NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"privacy"  ofType:@".txt"] encoding:NSUTF8StringEncoding error:nil];
    }else{
        ekspatext.text = [NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"privacy1"  ofType:@".txt"] encoding:NSUTF8StringEncoding error:nil];
    }
    
    [ekspabgview addSubview:ekspatext];
    
    
    
    
    
    
    
    
    
    
    atcancelButton= [UIButton buttonWithType:UIButtonTypeCustom];
    atcancelButton.backgroundColor = [UIColor colorWithHexString:@"#E5E5E5"];
    [atcancelButton setTitleColor:[UIColor colorWithHexString:@"#666666"] forState:UIControlStateNormal];
    atcancelButton.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size: 16];
    atcancelButton.clipsToBounds = YES;
    atcancelButton.layer.cornerRadius = 20;
    
    atcancelButton.frame= CGRectMake(17, ekspabgview.height-15-40 ,114, 40);
    
    [atcancelButton setTitle:NSLocalizedString(@"cancal", nil) forState:UIControlStateNormal];
    
    [atcancelButton addTarget:self action:@selector(cancelButtonclick:) forControlEvents:UIControlEventTouchUpInside];
    [ekspabgview addSubview:atcancelButton];
    
    
    
    
    
    
    
    attureButton= [UIButton buttonWithType:UIButtonTypeCustom];
   
    attureButton.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size: 16];
    [attureButton setTitleColor:[UIColor whiteColor]
                       forState:UIControlStateNormal];
   
    attureButton.frame= CGRectMake(ekspabgview.width-15-114, ekspabgview.height-15-40, 114, 40);
    atcancelButton.clipsToBounds = YES;
    attureButton.layer.cornerRadius = 20;
    CAGradientLayer *gl = [CAGradientLayer layer];
    gl.frame = CGRectMake(0,0,114,40);
    gl.startPoint = CGPointMake(0, 0);
    gl.endPoint = CGPointMake(1, 1);
    gl.colors = @[(__bridge id)[UIColor colorWithRed:252/255.0 green:87/255.0 blue:144/255.0 alpha:1.0].CGColor, (__bridge id)[UIColor colorWithRed:246/255.0 green:55/255.0 blue:49/255.0 alpha:1.0].CGColor];
    gl.locations = @[@(0), @(1.0f)];
    gl.cornerRadius = 20;
    [attureButton.layer insertSublayer:gl atIndex:0];
    [attureButton setTitle:NSLocalizedString(@"ture", nil) forState:UIControlStateNormal];
    
    [attureButton addTarget:self action:@selector(tureButtonclick:) forControlEvents:UIControlEventTouchUpInside];
    [ekspabgview addSubview:attureButton];
    
    
    
}
-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        [self initView];
    }
    return self;
}

-(void)cancelButtonclick:(UIButton *)button{
    
    
    self.cancelBlock(button);
    
    
}
-(void)tureButtonclick:(UIButton *)button{
    
    
    self.tureBlock(button);
    
    
}




@end
